package com.youkeda.meetingroom.auth;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * 拦截请求，登录鉴权
 *
 * @author: Awake
 * @date: 2019-07-16 15:39
 **/
@Component
public class TokenInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
        Object handler) throws Exception {
        String userId = (String) request.getSession().getAttribute("userId");
        if (userId != null) {
            request.setAttribute("userId", userId);
        }
        return true;
    }

}
